home *** CD-ROM | disk | FTP | other *** search
/ Hráč 2004 August / Hrac_72_2004-08_dvd.iso / dema / Rapid Gun / rg_setup.exe / common / image_PencilSketch.fx < prev    next >
Text File  |  2004-04-19  |  2KB  |  101 lines

  1. // LF2 Engine
  2. // (C) 2002-3 7FX
  3. //---------------------------------------------------------------------------
  4. // Desc
  5. string desc : Description = "Image shader - pencil sketch.";
  6. // Shader type phase
  7. string type : Type = "image";
  8. //---------------------------------------------------------------------------
  9. // Render target texture
  10. texture RT : RenderTargetFSMap;
  11. // Stroke pattern texture
  12. texture2D Stroke
  13. <
  14.     string file = "hatchrb.jpg";
  15. >;
  16. //---------------------------------------------------------------------------
  17. sampler sRT = sampler_state
  18. {
  19.     Texture = <RT>;
  20.     MinFilter = POINT;
  21.     MagFilter = POINT;
  22.     AddressU = CLAMP;
  23.     AddressV = CLAMP;
  24. };
  25. //---------------------------------------------------------------------------
  26. sampler sStroke = sampler_state
  27. {
  28.     Texture = <Stroke>;
  29.     MinFilter = LINEAR;
  30.     MagFilter = LINEAR;
  31.     MipFilter = POINT;
  32. };
  33. //---------------------------------------------------------------------------
  34. float c0 = 0.5;
  35. float3 c1 = {1.0, 0.0, 0.0};
  36. float3 c2 = {0.0, 0.0, 1.0};
  37. // Constant for luminance calculation
  38. const float4 cLum = {0.3f, 0.59f, 0.11f, 1.f};
  39.  
  40. // Pixel shader
  41. float4 PS(float2 uv: TEXCOORD0) : COLOR
  42. {
  43.     float3 samp = 4 * tex2D(sRT, uv);
  44.     
  45.     float3 r0 = saturate(samp * c0);
  46.     r0 = (1-r0) * (1-tex2D(sStroke, 12*uv).rgb);
  47.      
  48.     float4 r1 = saturate(dot(r0, c1));
  49.     r1.rgb = saturate(dot(r0, c2));
  50.     
  51.     r1.rgb = (1-r1) * (1-r1.a);
  52.     
  53.     r0 = saturate(samp);
  54.  
  55.     r0 = (saturate(2*(r1 - 0.25)) * r0);
  56.     
  57.     return float4(r0, 1);
  58. }
  59. //---------------------------------------------------------------------------
  60. technique vs0_ps11
  61. {
  62.     pass p0
  63.     {
  64.            ZEnable = false;
  65.         ZWriteEnable = false;
  66.    
  67.         PixelShader = compile ps_2_0 PS();
  68.    
  69.         /*Sampler[0] = <sRT>;
  70.         Sampler[1] = <sStroke>;
  71.  
  72.         PixelShader  = asm
  73.         {
  74.             ps.1.1
  75.             
  76.             def c0, 0.3, 0.3, 0.3, 0.0
  77.             def c1, 1.0, 0.0, 0.0, 0.0
  78.             def c2, 0.0, 0.0, 1.0, 0.0
  79.             
  80.             tex t0
  81.             tex t1
  82.             
  83.             mul_x4_sat r0.rgb, t0, c0
  84.             mul r0.rgb, 1-r0, 1-t1
  85.             
  86.             dp3_sat r1.rgba, r0, c1
  87.             dp3_sat r1.rgb, r0, c2
  88.             
  89.             mul r1.rgb, 1-r1, 1-r1.a
  90.             
  91.             mov_x4_sat r0.rgb, t0
  92.             
  93.             mul r0.rgb, r1_bx2, r0
  94.             
  95.             mov_x2 r0.rgb, r0, v0
  96.             + mov r0.a, c1.r 
  97.             
  98.         };*/
  99.     }
  100. }
  101. //---------------------------------------------------------------------------